//
//  HttpUtils.m
//  iosTestDemo
//
//  Created by 证联 on 2022/7/1.
//

#import "HttpUtils.h"

@implementation HttpUtils

/// 请求地址
/// @param uid 请求编号
+ (NSString *)path:(NSString *)uid{
    NSMutableDictionary *dic =[NSMutableDictionary dictionary];
    dic[@"R010201"]=@"register";
    dic[@"R010301"]=@"login";
    dic[@"R010401"]=@"loginOut";
    dic[@"R010101"]=@"getToken";
    
    return [dic objectForKey:uid] ;
}
/**
 获取随机数
 */
+(nullable NSString *)reqSeqId{
    int a;
    NSString *reqSeqId;
    NSMutableArray *mArr = [NSMutableArray array];
       for( a = 0; a < 32; a++ ) {

           //取 0～10 之间的随机数
           int    random=   arc4random_uniform(9);
           //数组添加数据
           [mArr addObject:[NSNumber numberWithInt:random]];
       }
     //将数组数据拼接字符串
    NSString *res = [mArr componentsJoinedByString:@""];
    return res;
}
/**
 获取时间戳
 */
+(nullable NSString *) timeStamp :(NSString *) str{
  NSDate *date=  [NSDate dateWithTimeIntervalSinceNow:0];
    //声明
    NSDateFormatter *dateFormatter =[[NSDateFormatter alloc] init];
    //输出格式通过setDateStyle和setTimeStyle设置,分别定义的日期和时间的格式可选一下的系统给出的方法
    [dateFormatter setDateStyle:NSDateFormatterFullStyle];
    //设置格式
    [dateFormatter setDateFormat:str];
    NSString *time = [dateFormatter stringFromDate:date];
   
    return time;
}
/**
 获取十六进制32位字符串
 */
+ (NSString *)sm4Key{
    NSString *key = @"0123456789abcdef";
    //设置可变字符串
    NSMutableString *mutStr=[[NSMutableString alloc] init];
    int i;
    for (i = 0; i<32; i++ ){
        //0-15 之间的随机数
        int num =arc4random_uniform(16);
        //根据随机数(下标)获取key
        char ca=   [key characterAtIndex:num];
        //拼接 字符串
        [mutStr appendFormat:@"%c",ca];
    }
//    NSLog(@"%@",mutStr);
    return mutStr;
}
@end
